package com.meessiom.train.crm.fundsrecoverymanagement.controller;

import com.meessiom.train.crm.fundsrecoverymanagement.model.Fundsrecoverymanagement;
import com.meessiom.train.crm.fundsrecoverymanagement.repository.FundsrecoverymanagementRepository;
import com.meessiom.train.crm.fundsrecoverymanagement.service.FundsrecoverymanagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/api/v1/fundsrecoverymanagement")
public class FundsrecoverymanagementController {
    @Autowired
    private FundsrecoverymanagementService fundsrecoverymanagementService;
    @Autowired
    private FundsrecoverymanagementRepository fundsrecoverymanagementRepository;

    public FundsrecoverymanagementController() {
    }
    @GetMapping
    public List<Fundsrecoverymanagement> getAllFundsrecoverymanagement() {
        return fundsrecoverymanagementService.getAllFundsrecoverymanagement();
    }

    @PostMapping
    public Fundsrecoverymanagement createFundsrecoverymanagement(@RequestBody Fundsrecoverymanagement fundsrecoverymanagement) {
        return fundsrecoverymanagementService.createFundsrecoverymanagement(fundsrecoverymanagement);
    }

    @GetMapping("/{id}")
    public ResponseEntity<Fundsrecoverymanagement> getFundsrecoverymanagementById(@PathVariable Long id) {
        Fundsrecoverymanagement fundsrecoverymanagement = fundsrecoverymanagementService.getFundsrecoverymanagementById(id);
        return ResponseEntity.ok(fundsrecoverymanagement);
    }

    @DeleteMapping("/{id}")
    public ResponseEntity<Void> deleteFundsrecoverymanagement(@PathVariable Long id) {
        fundsrecoverymanagementService.deleteFundsrecoverymanagement(id);
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }
}
